<template>

  <BasicDrawer v-bind="$attrs" title="" @register="registerDrawer" width="1200px">
    <BasicTable @register="registerTable">
      <template v-slot:bodyCell="{columns, record, index}">
      </template>
    </BasicTable>
  </BasicDrawer>
</template>
<script lang="ts" setup>
  import { ref, unref,reactive } from 'vue';
  import { BasicDrawer,useDrawerInner } from '/@/components/Drawer';
  import { useListPage } from '/@/hooks/system/useListPage';
  import { BasicTable, TableAction } from '/@/components/Table';
  import { useDesign } from '/@/hooks/web/useDesign';
  import { list} from './CCompanyInfoDetails.api';
  import {BasicColumn} from '/@/components/Table';
  import { mapTableTotalSummary } from '@/utils/common/compUtils';
  let companyId = '';
  //接收id
  const [registerDrawer] = useDrawerInner(async (data) => {
    companyId = data.id
	//刷新
	reload();
  });
 const columns: BasicColumn[] = [
   {
     title: '总包',
     align: "center", resizable: true,
     dataIndex: 'companyId_dictText'
   },
/*   {
     title: '收款id',
     align: "center", resizable: true,
     dataIndex: 'recordId_dictText'
   },
   {
     title: '付款id',
     align: "center", resizable: true,
     dataIndex: 'requestId_dictText'
   },*/
   {
     title: '金额',
     align: "center", resizable: true,
     dataIndex: 'amount'
   },
   {
     title: '项目',
     align: "center", resizable: true,
     dataIndex: 'projectId_dictText'
   },
   {
     title: '子项目',
     align: "center", resizable: true,
     dataIndex: 'subProjectId_dictText'
   },
];
  //注册table数据
  const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
    tableProps: {
      title: '资金记录',
      api: list,
      columns,
      canResize:false,
      useSearchForm: false,
      showSummary: true,
      summaryFunc: onSummary,
  /*    actionColumn: {
        width: 80,
        fixed: 'right',
      },*/
        beforeFetch: async (params) => {
        const defaultParams = { 'companyId': companyId };
          return Object.assign(params, defaultParams);
        },
      afterFetch: (data) => {
        return data;
      },
    },
  });
  
  const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource },
  { rowSelection, selectedRowKeys }] = tableContext;
  const labelCol = reactive({
    xs: 24,
    sm: 4,
    xl: 6,
    xxl: 4
  });
  const wrapperCol = reactive({
    xs: 24,
    sm: 20,
  });
//列表数据
  function onSummary(tableData: Recordable[]) {
    // 可用工具方法自动计算合计
    const totals = mapTableTotalSummary(tableData, ['amount']);
    return [
      totals,
      {
        totalContractor: totals
      },
    ];
  }

</script>
<style scoped lang="less">
  @prefix-cls: ~'@{namespace}-row-invalid';

  :deep(.@{prefix-cls}) {
    background: #f4f4f4;
    color: #bababa;
  }
</style>
